home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / khexedit / clipboardinterface.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  3.1 KB  |  87 lines

  1. /***************************************************************************
  2.                           clipboardinterface.h  -  description
  3.                              -------------------
  4.     begin                : Sat Sep 13 2003
  5.     copyright            : (C) 2003 by Friedrich W. H. Kossebau
  6.     email                : Friedrich.W.H@Kossebau.de
  7.  ***************************************************************************/
  8.  
  9. /***************************************************************************
  10.  *                                                                         *
  11.  *   This library is free software; you can redistribute it and/or         *
  12.  *   modify it under the terms of the GNU Library General Public           *
  13.  *   License version 2 as published by the Free Software Foundation.       *
  14.  *                                                                         *
  15.  ***************************************************************************/
  16.  
  17.  
  18. #ifndef CLIPBOARDINTERFACE_H
  19. #define CLIPBOARDINTERFACE_H
  20.  
  21. namespace KHE
  22. {
  23.  
  24. /**
  25.  * @short A simple interface for interaction with the clipboard
  26.  *
  27.  * This interface enables the interaction with the clipboard. It relies on the
  28.  * possibilities of signal/slot so a class B that implements this interface
  29.  * should be derived from QObject. When connecting to a signal or a slot
  30.  * the class B has to be used, not the interface.
  31.  * <p>
  32.  * Example:
  33.  * \code
  34.  * KHE::ClipboardInterface *Clipboard = KHE::clipboardInterface( BytesEditWidget );
  35.  * if( Clipboard )
  36.  * {
  37.  * á // Yes, use BytesEditWidget, not Clipboard, because that's the QObject, indeed hacky...
  38.  * á connect( BytesEditWidget, SIGNAL(copyAvailable(bool)), this, SLOT(offerCopy(bool)) );
  39.  * }
  40.  * \endcode 
  41.  *
  42.  * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de>
  43.  * @see createBytesEditWidget(), clipboardInterface()
  44.  * @since 3.2
  45.  */
  46. class ClipboardInterface
  47. {
  48.   public: // slots
  49.     /** tries to copy. If there is nothing to copy this call is a noop. */
  50.     virtual void copy() = 0;
  51.     /** tries to cut. If there is nothing to cut this call is a noop. */
  52.     virtual void cut() = 0;
  53.     /** tries to paste. 
  54.       * If there is nothing to paste or paste is not possible this call is a noop.
  55.       * Use BytesEditInterface::isReadOnly() to find out if you can paste at all.
  56.       */
  57.     virtual void paste() = 0;
  58.  
  59.   public: // signals
  60.     /** signal: tells whether copy is possible or not.
  61.       * Remember to use the created object, not the interface for connecting
  62.       * Use BytesEditInterface::isReadOnly() to find out if you can also cut
  63.       * As this function symbol serves as a signal, this is a noop. Don't use it
  64.       * for anything else.
  65.       */
  66.     virtual void copyAvailable( bool Really ) = 0;
  67. };
  68.  
  69.  
  70. /** tries to get the clipboard interface of t   
  71.   * @return a pointer to the interface, otherwise 0
  72.   * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de>
  73.   * @since 3.2
  74. */
  75. template<class T>
  76. ClipboardInterface *clipboardInterface( T *t )
  77. {
  78.   if( !t )
  79.     return 0;
  80.  
  81.   return static_cast<ClipboardInterface*>( t->qt_cast("KHE::ClipboardInterface") );
  82. }
  83.  
  84. }
  85.  
  86. #endif
  87.